package cn.udrm.water.base.v1.waterdelivery.repository;

import javax.validation.constraints.NotNull;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.udrm.water.base.v1.waterdelivery.entities.CanalSystemSection;

@Repository
public interface CanalSystemSectionRepository extends JpaRepository<CanalSystemSection, String>
			, JpaSpecificationExecutor<CanalSystemSection>{
	
	@EntityGraph(value="CanalSystemSection.all", type=EntityGraphType.FETCH)
	public Page<CanalSystemSection> findAll(@NotNull Specification<CanalSystemSection> specification, Pageable pageable);
	
	@Query(value="FROM CanalSystemSection w WHERE w.id=?1")
	@EntityGraph(value="CanalSystemSection.all", type=EntityGraphType.FETCH)
	public CanalSystemSection findAllById(String id);
	
}
